// pages/cate/add/index.js
import { tips, confirm, coludRequest } from '../../util/util.js' 
Page({

  /**
   * 页面的初始数据
   */
  data: {
      title:''
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },
  
  getTitle: function (e) {
    var val = e.detail.value;
    this.setData({title: val});
  },

  submitAdd:function(){
    if(this.data.title==""){
       tips('请输入分类');
       return false;
    } 
    coludRequest('admin', { module:'cate',action:'add', params: { title: this.data.title }},function(res){
      tips('分类添加成功')
      setTimeout(res => {
        wx.navigateTo({
          url: '/pages/cate/index',
        })
      }, 1200)
    })    
  }

})